Skip to main content

Adding Rainfall to INP File.

Functional Specifications

Sections that need to be modified or replaced.

  1. OPTIONS
  2. RAINGAGES
  3. SUBCATCHMENTS
  4. TIMESERIES

OPTIONS

fields that need modified are START_DATE START_TIME REPORT_START_DATE REPORT_START_TIME END_DATE END_TIME

RAINGAGES

CVG will need to be added as a rain gage.

SUBCATCHMENTS

All the Subcatchments's rain gage needs to be changed to CVG.

TIMESERIES

The rainfall data from the rainfall file will need to be placed in the TIMESERIES section.

If we want to make the INP files more readable we should replace the data in the RAINGAGES and TIMESERIES sections so additional rain gages are not available.

Design Specifications

This does require reading an INP file and Modifying it. This is the same way we are currently generating a new plume in Banklick. There is no API that will do this for us currently. US EPA will not be providing this API in the first release of EPA-PySWMM.

Read the Rainfall File it should be placed in a pandas Dataframe called df_rain.

In this file there should be a station column which should be CVG a DateTime and a Rainfall.

Get the Value of The 1st station which should be CVG this and save it as a station_name.

Get the Min and Max date time for the Rainfall. Parse this string for Start_Date and Start_Time and End_Date and End_Time.

Now start on the sections of the INP file.

Print the comments to the INP file. A comment starts with a ';'. It makes it easier for whoever needs to read it later. Note Formatting in INP file can be either tabs or spaces.

To Navigate the INP file we will use the words in [] The only pace brackets are used in an INP file is for section names therefore we can start with a Section name in Brackets and continue until we reach the next open bracket '['

If the section starts with [RAINGAGES] Then Replace it with the following:

;;Name Format Interval SCF Source ;;-------------- --------- ------ ------ ---------- ;CVG CVG VOLUME 0:05 1.0 TIMESERIES CVG

If the section starts with [TIMESERIES]. The replace it with the pandas Dataframe df_rain. It should already be in the correct format. If the pandas dataframe prints the column headers then we will need to add a ; before the headers.

Both of the sections described are the easier sections as we want to replace the entire section.

If the section starts with [SUBCATCHMENTS]. I need to scrape the subcatchment section into a pandas dataframe called df_subcatchment. If there are any lines that start with ; they need to be written back to the file. Then I will need to set the column for the Raingage (This should be the second column of the pandas dataframe) to the station_name. Then I will replace the section with the Dataframe.

If the section starts with [OPTIONS]. The options section will also need to be scraped into a pandas dataframe called df_options. In this section There should only be 2 columns options and values. The dataframe will be iterated through and if the value is START_DATE, START_TIME, REPORT_START_DATE, REPORT_START_TIME, END_DATE, or END_TIME then the data will need to be modified by the saved values start_date, start_time, end_date or end_time. If statements will be used. Then replace the section with the dataframe.